#include <stdio.h>
#define SIZE 100
#define ORDER 25

int quick_partition(int *arr,int l,int r)
{
	if(r - l < 1)
	{
		return l;
	}
	int key = arr[l],step = l,flag = 0;
	l++;
	while(r >= l)
	{
		if(flag == 0)
		{
			if(arr[r--] < key)
			{
				arr[step] = arr[r + 1];
				step = r + 1;
				flag = 1;
			}
		}
		else 
		{
			if(arr[l++] > key)
			{
				arr[step] = arr[l - 1];
				step = l - 1;
				flag = 0;
			}
		}
	}
	arr[step] = key;
	return step;
}

int select(int *arr, int x, int n)
{
	int mid = quick_partition(arr,0,n - 1);
	int l = 0,r = n - 1;
	while(x != mid)
	{
		if(x < mid)
		{
			r = mid - 1;
		}
		else 
		{
			l = mid + 1;
		}
		mid = quick_partition(arr,l,r);
	}
	return arr[mid];
}

int selectMid(int *arr, int n)
{
	if(n % 2 == 1)
		return select(arr,n / 2,n);
	int l = 0,r = n - 1,n1 = n / 2 - 1,n2 = n / 2;
	int mid = quick_partition(arr,l,r);
	while(n1 != mid && n2 != mid)
	{
		if(n2 < mid)
		{
			r = mid - 1;
		}
		else 
		{
			l = mid + 1;
		}
		mid = quick_partition(arr,l,r);
	}
	int temp,x;
	if(n1 == mid)
	{
		x = n2;
		temp = arr[n1];
		l = mid + 1;
	}
	else
	{
		x = n1;
		temp = arr[n2];
		r = mid - 1;
	}
	mid = quick_partition(arr,l,r);
	while(x != mid)
	{
		if(x < mid)
		{
			r = mid - 1;
		}
		else 
		{
			l = mid + 1;
		}
		mid = quick_partition(arr,l,r);
	}
	return (temp + arr[mid]) / 2;
}

int main()
{
	int arr[SIZE];
	for(int i = 0;i < SIZE;i++)
	{
		scanf("%d",&arr[i]);
	}
	printf("%d ",select(arr,ORDER,SIZE));
	printf("%d\n",selectMid(arr,SIZE));
	return 0;
}
